package com.redrose.demo.fragment;

import androidx.annotation.LayoutRes;

import com.redrose.demo.bean.ListItem;
import com.redrose.demo.multiple.BaseMultiLayoutAdapter;

import java.util.List;

public abstract class HomeBaseAdapter extends BaseMultiLayoutAdapter<ListItem> {
    public HomeBaseAdapter(List<ListItem> list) {
        super(list);
    }

    @Override
    public int getItemViewType(int position) {
        return mList.get(position).getItemType();
    }

    // TODO 通过viewType 获取layoutResId
    @LayoutRes
    protected int getListItem(int viewType) {
        final int[] layoutRes = new int[1];
        mList.forEach(listItem -> {
            if (listItem.getItemType() == viewType) {
                layoutRes[0] = listItem.getLayoutResId();
            }
        });
        return layoutRes[0];
    }
}
